import pandas as pd
from matplotlib import pyplot as plt
import matplotlib

matplotlib.rc("font", family='Source Han Sans CN', weight="regular", size="10")

file_path = "csv/IMDB-Movie-Data.csv"
df = pd.read_csv(file_path)

runtime_data = df["Runtime (Minutes)"].values
max_runtime = runtime_data.max()
min_runtime = runtime_data.min()
d = 5
bins = (max_runtime - min_runtime) // d

plt.figure(figsize=(15, 10))
plt.grid()

plt.xlabel("时长/分钟")
plt.ylabel("数量")
plt.title("1000部电影时长分析的频数直方图", weight="bold", size="16")
plt.xticks(range(min_runtime, max_runtime + d, d))

plt.hist(runtime_data, bins)
plt.show()
